#ifndef POINT3D_H
#define POINT3D_H

#include <GL/gl.h>

#include "vec3.h"
#include "primitive_types.h"

class Point3D
{
public:
    explicit Point3D( void );
    Point3D( const Point3D& p );
    Point3D( real x , real y , real z);
    Point3D( real x ) { (*this) = Point3D( x , x , x ); }
    Point3D( Vec3 poss );
    Point3D &operator=( const Point3D &p ) ;

    Point3D afineSum( real alpha , Point3D p) const;
    static Point3D afineSum( Point3D p1, Point3D p2, float alpha);

    real& operator[](uint i) { AssertBound(i < 3) ; return pPoss[i] ; }
    real  operator[](uint i) const { AssertBound(i < 3) ; return pPoss[i] ; }

    const Vec3 operator-( Point3D p0 ) const;
    const Point3D operator+( Vec3 v ) const;
    void operator+=( const Vec3& v );
    Point3D operator*(double t);

    bool operator==(const Point3D& v) const;
    bool operator!=(const Point3D& v) const;

    real x( void ) const;
    real y( void ) const;
    real z( void ) const;

    void x( real x );
    void y( real y );
    void z( real z );

    Vec3 toVec3( void ) const ;
    Vec3 toVector( void ) const ;
    void set( const Vec3 v );

    Point3D min(const Point3D& p) const;
    Point3D max(const Point3D& p) const;

    real min( real x , real y ) const;
    real max( real x , real y ) const;

private:
    Vec3 pPoss;
};

#endif // POINT3D_H
